
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta charset="utf-8" />
    <title>Python运行时服务 &#8212; Python 3.7.8 文档</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="在 Python 3.7.8 文档 中搜索"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="关于这些文档" href="../about.html" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="copyright" title="版权所有" href="../copyright.html" />
    <link rel="next" title="sys --- 系统相关的参数和函数" href="sys.html" />
    <link rel="prev" title="zipapp --- Manage executable Python zip archives" href="zipapp.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/library/python.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="sys.html" title="sys --- 系统相关的参数和函数"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="zipapp.html" title="zipapp --- Manage executable Python zip archives"
             accesskey="P">上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python 标准库</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="python-runtime-services">
<span id="python"></span><h1>Python运行时服务<a class="headerlink" href="#python-runtime-services" title="永久链接至标题">¶</a></h1>
<p>本章里描述的模块提供了和Python解释器及其环境交互相关的广泛服务。以下是综述：</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="sys.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code> --- 系统相关的参数和函数</a></li>
<li class="toctree-l1"><a class="reference internal" href="sysconfig.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code> --- Provide access to Python's configuration information</a><ul>
<li class="toctree-l2"><a class="reference internal" href="sysconfig.html#configuration-variables">配置变量</a></li>
<li class="toctree-l2"><a class="reference internal" href="sysconfig.html#installation-paths">安装路径</a></li>
<li class="toctree-l2"><a class="reference internal" href="sysconfig.html#other-functions">其他功能</a></li>
<li class="toctree-l2"><a class="reference internal" href="sysconfig.html#using-sysconfig-as-a-script">Using <code class="xref py py-mod docutils literal notranslate"><span class="pre">sysconfig</span></code> as a script</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="builtins.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">builtins</span></code> --- 内建对象</a></li>
<li class="toctree-l1"><a class="reference internal" href="__main__.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">__main__</span></code> --- 顶层脚本环境</a></li>
<li class="toctree-l1"><a class="reference internal" href="warnings.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code> --- Warning control</a><ul>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#warning-categories">警告类别</a></li>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#the-warnings-filter">The Warnings Filter</a><ul>
<li class="toctree-l3"><a class="reference internal" href="warnings.html#describing-warning-filters">Describing Warning Filters</a></li>
<li class="toctree-l3"><a class="reference internal" href="warnings.html#default-warning-filter">默认警告过滤器</a></li>
<li class="toctree-l3"><a class="reference internal" href="warnings.html#overriding-the-default-filter">Overriding the default filter</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#temporarily-suppressing-warnings">暂时禁止警告</a></li>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#testing-warnings">测试警告</a></li>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#updating-code-for-new-versions-of-dependencies">Updating Code For New Versions of Dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#available-functions">Available Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="warnings.html#available-context-managers">Available Context Managers</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="dataclasses.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">dataclasses</span></code> --- 数据类</a><ul>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#module-level-decorators-classes-and-functions">模块级装饰器、类和函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#post-init-processing">初始化后处理</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#class-variables">类变量</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#init-only-variables">仅初始化变量</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#frozen-instances">冻结的实例</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#inheritance">继承</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#default-factory-functions">默认工厂函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#mutable-default-values">可变的默认值</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataclasses.html#exceptions">异常</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contextlib.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contextlib</span></code> --- Utilities for <code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code>-statement contexts</a><ul>
<li class="toctree-l2"><a class="reference internal" href="contextlib.html#utilities">工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="contextlib.html#examples-and-recipes">例子和配方</a><ul>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#supporting-a-variable-number-of-context-managers">Supporting a variable number of context managers</a></li>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#catching-exceptions-from-enter-methods">Catching exceptions from <code class="docutils literal notranslate"><span class="pre">__enter__</span></code> methods</a></li>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#cleaning-up-in-an-enter-implementation">Cleaning up in an <code class="docutils literal notranslate"><span class="pre">__enter__</span></code> implementation</a></li>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#replacing-any-use-of-try-finally-and-flag-variables">Replacing any use of <code class="docutils literal notranslate"><span class="pre">try-finally</span></code> and flag variables</a></li>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#using-a-context-manager-as-a-function-decorator">Using a context manager as a function decorator</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="contextlib.html#single-use-reusable-and-reentrant-context-managers">Single use, reusable and reentrant context managers</a><ul>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#reentrant-context-managers">Reentrant context managers</a></li>
<li class="toctree-l3"><a class="reference internal" href="contextlib.html#reusable-context-managers">Reusable context managers</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="abc.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">abc</span></code> --- 抽象基类</a></li>
<li class="toctree-l1"><a class="reference internal" href="atexit.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">atexit</span></code> --- 退出处理器</a><ul>
<li class="toctree-l2"><a class="reference internal" href="atexit.html#atexit-example"><code class="xref py py-mod docutils literal notranslate"><span class="pre">atexit</span></code> 示例</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="traceback.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">traceback</span></code> --- 打印或检索堆栈回溯</a><ul>
<li class="toctree-l2"><a class="reference internal" href="traceback.html#tracebackexception-objects"><code class="xref py py-class docutils literal notranslate"><span class="pre">TracebackException</span></code> Objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="traceback.html#stacksummary-objects"><code class="xref py py-class docutils literal notranslate"><span class="pre">StackSummary</span></code> Objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="traceback.html#framesummary-objects"><code class="xref py py-class docutils literal notranslate"><span class="pre">FrameSummary</span></code> Objects</a></li>
<li class="toctree-l2"><a class="reference internal" href="traceback.html#traceback-examples">Traceback Examples</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="__future__.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">__future__</span></code> --- Future 语句定义</a></li>
<li class="toctree-l1"><a class="reference internal" href="gc.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">gc</span></code> --- 垃圾回收器接口</a></li>
<li class="toctree-l1"><a class="reference internal" href="inspect.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">inspect</span></code> --- 检查对象</a><ul>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#types-and-members">类型和成员</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#retrieving-source-code">Retrieving source code</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#introspecting-callables-with-the-signature-object">Introspecting callables with the Signature object</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#classes-and-functions">类与函数</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#the-interpreter-stack">The interpreter stack</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#fetching-attributes-statically">Fetching attributes statically</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#current-state-of-generators-and-coroutines">Current State of Generators and Coroutines</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#code-objects-bit-flags">Code Objects Bit Flags</a></li>
<li class="toctree-l2"><a class="reference internal" href="inspect.html#command-line-interface">命令行界面</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="site.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code> —— 指定 Site 的配置钩子</a><ul>
<li class="toctree-l2"><a class="reference internal" href="site.html#readline-configuration">Readline configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="site.html#module-contents">模块内容</a></li>
<li class="toctree-l2"><a class="reference internal" href="site.html#command-line-interface">命令行界面</a></li>
</ul>
</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>上一个主题</h4>
  <p class="topless"><a href="zipapp.html"
                        title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipapp</span></code> --- Manage executable Python zip archives</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="sys.html"
                        title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code> --- 系统相关的参数和函数</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">提交 Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/library/python.rst"
            rel="nofollow">显示源代码
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="sys.html" title="sys --- 系统相关的参数和函数"
             >下一页</a> |</li>
        <li class="right" >
          <a href="zipapp.html" title="zipapp --- Manage executable Python zip archives"
             >上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">版权所有</a> 2001-2020, Python Software Foundation.
    <br />
    Python 软件基金会是一个非盈利组织。
    <a href="https://www.python.org/psf/donations/">请捐助。</a>
    <br />
    最后更新于 6月 29, 2020.
    <a href="../bugs.html">发现了问题</a>？
    <br />
    使用<a href="http://sphinx.pocoo.org/">Sphinx</a>2.3.1 创建。
    </div>

  </body>
</html>